﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using NS.Utilities;
using NS.BLL.Systems;
using BLL;
using Model;

public partial class Platform_PriceManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            GridViewDataBind();
        }
    }

    private void GridViewDataBind()
    {
        FGridView1.SQLString = PriceService.GetAllPrice_SQL();
        FGridView1.PKey = "ID";
        FGridView1.OrderName = "ID";
        FGridView1.BindData();
        FGridView1.AddControl();
    }
    protected void btnBindData_Click(object sender, EventArgs e)
    {
        GridViewDataBind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Price Model = new Price();
        Model.PriceType = txtPriceType.Text.Trim();
        Model.OutPrice = decimal.Parse(txtOutPrice.Text.Trim());
        Model.InPrice = decimal.Parse(txtInPrice.Text.Trim());
        if (PriceService.AddPrice(Model) > 0)
        {
            GridViewDataBind();
        }
        else
        {
            MessageBox.ShowSaveError(this);
        }
    }

    protected void btnDel_Click(object sender, EventArgs e)
    {
        string ID = ((Button)sender).CommandArgument.ToString();
        PriceService.DeletePriceById(Convert.ToInt32(ID));
        GridViewDataBind();
    }
}